import requests

sess = requests.session()

IP = "192.168.1.7"
#1.表单上传接口
def file_upload():
    #1.传入文件的路径
    path = "D:\\aaa.png"
    #2.打开文件 并传入 files变量中
    with open(path,"rb") as f:
        #file是fiddler抓包中 name属性的值
        files ={"file":(path,f)}
    #3.文件上传
        rp=sess.request("post","http://"+IP+":8080/pinter/file/api/upload",files=files)
    print(rp.text)
#2.Ajax上传接口
def file_upload2():
    #1.传入文件的路径
    path = "D:\\aaa.png"
    #2.打开文件 并传入 files变量中
    with open(path,"rb") as f:
        #file是fiddler抓包中 name属性的值
        files ={"file":(path,f)}
    #3.文件上传
        rp=sess.request("post","http://"+IP+":8080/pinter/file/api/upload2",files=files)
    print(rp.text)

#3.文件下载接口
def file_download():
    #1.传入下载文件的编号
    params ={"id":1}
    #2.文件下载
    rp =sess.request("get","http://"+IP+":8080/pinter/file/api/download",params=params)
    print(rp.text)

if __name__=='__main__':
    file_upload()
    file_download()